/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.OneCommerceProject.beans;

import com.OneCommerceProject.entities.Item;
import com.OneCommerceProject.entities.Utilisateur;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Aymen
 */
@Stateless
public class ItemFacade extends AbstractFacade<Item> {

    @PersistenceContext(unitName = "OneCommerceProjectPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ItemFacade() {
        super(Item.class);
    }

    public List<Item> findByCategory(String idCategory) {
        
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("category", idCategory);
        return super.findMultipleResults(Item.FIND_BY_CATEGORY, parameters);
    }
    
    public List<Item> findAllOrderByVente() {        
        Map<String, Object> parameters = new HashMap<String, Object>();        
        return super.findMultipleResults(Item.FIND_ALL_ORDER_BY_VENTE, parameters);
    }
    
    public List<Item> findAllOrderByVenteDesc() {        
        Map<String, Object> parameters = new HashMap<String, Object>();        
        return super.findMultipleResults(Item.FIND_ALL_ORDER_BY_VENTE_DESC, parameters);
    }
    
    public Item findByIdItem(BigDecimal iditem) {
        Map<String, Object> parameters = new HashMap<String, Object>();
	parameters.put("iditem", iditem);		
        return super.findOneResult(Item.FIND_BY_IDITEM, parameters);
    }
}
